package com.kamistoat.ruoyi.ruoyiapisystem.feign;

import com.kamistoat.ruoyi.ruoyiapisystem.domain.SysLogininfor;
import com.kamistoat.ruoyi.ruoyiapisystem.domain.SysOperLog;
import com.kamistoat.ruoyi.ruoyiapisystem.factory.RemoteLogFallbackFactory;
import com.kamistoat.ruoyi.ruoyicommoncore.constant.SecurityConstants;
import com.kamistoat.ruoyi.ruoyicommoncore.constant.ServiceNameConstants;
import com.kamistoat.ruoyi.ruoyicommoncore.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * 日志服务 feign接口
 */
@FeignClient(contextId = "remoteLogService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteLogFallbackFactory.class)
public interface RemoteLogService {

    /**
     * 保存系统日志
     *
     * @param sysOperLog SysOperLogEntity的vo类。要求使用JSON提交
     * @param source     请求来源.要求必须在请求header中含有该参数
     * @return 结果
     */
    @PostMapping("/operlog")
    public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 保存访问记录
     *
     * @param sysLogininfor SysLogininforEntity的vo类。JOSN格式
     * @param source        请求来源，位于请求Header中
     * @return 结果
     */
    @PostMapping("/logininfor")
    public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
